package com.kldy8.kldyw.filmfactory.dteam.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/26.
 */
public class Dteam
{
    public String dramatic_team_id;
    public String works_name;
    public String works_type;
    public String image;
    public List<Roles> rolesList;
    public String url;


    public static Dteam resolution(JSONObject jsonObject)
    {
        if (jsonObject == null)
        {
            return  null;
        }

        Dteam m_new = new Dteam();
        m_new.dramatic_team_id = jsonObject.optString("dramatic_team_id");
        m_new.url = jsonObject.optString("url");
        m_new.works_name = jsonObject.optString("works_name");
        m_new.works_type = jsonObject.optString("works_type");
        m_new.image = jsonObject.optString("image");
        m_new.rolesList = new ArrayList<Roles>();
        JSONArray arryJSOn = jsonObject.optJSONArray("roles");
        if (arryJSOn != null)
        {
            for (int i = 0 ;i <arryJSOn.length(); i++)
            {
               JSONObject roleObject =  arryJSOn.optJSONObject(i);
                Roles role = Roles.resolution(roleObject);
                m_new.rolesList.add(role);
            }
        }
        return m_new;
    }

    @Override
    public String toString() {
        return "Dteam{" +
                "dramatic_team_id='" + dramatic_team_id + '\'' +
                ", works_name='" + works_name + '\'' +
                ", works_type='" + works_type + '\'' +
                ", image='" + image + '\'' +
                ", rolesList=" + rolesList +
                ", url='" + url + '\'' +
                '}';
    }
}
